<head>
    <link href="${ctx}/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="${ctx}/font-awesome/3.0.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctx}/css/index.css" rel="stylesheet">
    <link href="${ctx}/bootstrap-table/1.12.0/bootstrap-table.min.css" rel="stylesheet">
    <script src="${ctx}/jquery/2.1.4/jquery.min.js"></script>
    <script src="${ctx}/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/bootstrap-table.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/extensions/export/bootstrap-table-export.min.js"></script>
    <script src="${ctx}/js/extends.js"></script>
    <script src="${ctx}/layui/layui.all.js"></script>
    <script src="${ctx}/js/util.js"></script>
    <link href="${ctx}/layui/css/layui.css" rel="stylesheet">
</head>
<title>收入明细</title>
<div class="lay-box">
    <form class="layui-form" action="" style="margin-top: 10px">
        <div class="layui-inline" style="margin: 0 0 8px 20px;">
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="star" placeholder="起始时间">
            </div>
        </div>
        <div class="layui-inline" style="margin: 0 0 8px 20px;">
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="end" placeholder="结束时间">
            </div>
        </div>
        <div class="layui-inline" style="float: left; width: 240px; margin-right:20px;">
            <select id="category" class="form-control">
                <option value="">选择任务类型</option>
                <#list list as category>
                    <option value="${category}">${category.title}</option>
                </#list>
            </select>
        </div>
        <div class="layui-input-inline">
            <input type="text" id="phone" class="layui-input" placeholder="请输入用户手机号" value="">
        </div>
        <div class="layui-input-inline">
            <input type="text" id="masterPhone" class="layui-input" placeholder="请输入师傅手机号" value=""></div>
        <div class="layui-input-inline">
            <input type="text" id="imei" class="layui-input" placeholder="请输入用户设备号" value=""></div>

        <div class="layui-input-inline">
            <input type="text" id="appStore" class="layui-input" placeholder="请输入用户渠道" value=""></div>
    </form>
    <span onclick="search()" class="btn btn-info" style="height: 38px;margin-left: 10px;font-size: 14px">查询</span>
    <table class="table table-border table-bordered table-hover table-bg table-sort" id="layTable"
           lay-filter="tableFilter">

    </table>
</div>

<style>
    .lay-box {
        padding: 8px 12px;
    }

    .layui-form-checkbox[lay-skin=primary] i {
        top: 5px;
    }
</style>
<script type="text/html" id="barDemo">

</script>


<script type="text/javascript">
    var startDate = "";
    var endDate = "";
    var searchKey = "";
    var tableIns;
    var ids = "";
    var form;
    var table = "member_new_trade";
    layui.use('table', function () {
        tableIns = layui.table,
            form = layui.form;
        form.render();
        tableIns.render({
            elem: '#layTable'
            ,
            url: '/sys/membernewtrade/datalist'
            ,
            method: 'POST'
            ,
            limit: 50
            ,
            where: {}
            ,
            toolbar:true,
            totalRow:true,
            initSort:"amount",
            id: 'dataTableId',
            // skin:'line',
            // even: true ,
            //  size: 'lg',
            cols: [[
                {
                    field: 'categoryTitle',
                    title: '收支描述',
                    width: 350,
                    align: 'center',
                    sort: true,totalRowText:'合计'
                } ,{
                    field: 'amount',
                    title: '金额',
                    width: 250,
                    align: 'center',
                    sort: true,
                    totalRow:true
                }
                , {
                    field: 'myAmount',
                    title: '用户带来的收益',
                    width: 250,
                    align: 'center',
                    sort: true,
                    totalRow:true
                }, {
                    field: 'isNewMember',
                    title: '新用户完成个数',
                    width: 250,
                    align: 'center',
                    sort: true,
                    totalRow:true
                }

                , {
                    field: 'isOldMember',
                    title: '老用户完成个数',
                    width: 250,
                    align: 'center',
                    sort: true,
                    totalRow:true
                }


            ]]
            ,
            page: true
        });

        form.on('switch(sexDemo)', function (obj) {
            // layer.tips(this.value + ' ' + this.name + '：'+ obj.elem.checked, obj.othis);
            if (obj.elem.checked) {
                commonenable(this.value, 1);
            } else {
                commonenable(this.value, 0);
            }

        });
        tableIns.on('checkbox(tableFilter)', function (obj) {
            var checkStatus = tableIns.checkStatus('dataTableId');
            var dataList = checkStatus.data;
            if (dataList != null && dataList.length > 0) {

                for (var i = 0; i < dataList.length; i++) {
                    ids += dataList[i].id + ",";
                }
            }
        });


        $("#multiDelete").click(function () {
            deleteId(ids)
        });

        tableIns.on('tool(tableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.msg('ID：' + data.id + ' 的查看操作');
            } else if (obj.event === 'del') {
                layer.confirm('真的删除行么', function (index) {
                    deleteId(data.id)
                    layer.close(index);
                });
            } else if (obj.event === 'save') {
                layer_show("修改", "/sys/membernewtrade/add?id=" + data.id, "650", "650");
            }
        });
    });
    $(function(){
        $('#search_input').bind('keyup', function(event) {
            if (event.keyCode === "13") {
                //回车执行查询
                search();
            }
        });
    });
    document.onkeydown = function(e){
        if(e.keyCode === 13){
            search();
        }
    }

    function search() {
        let imei = $("#imei").val();
        let phone = $("#phone").val();
        let masterPhone = $("#masterPhone").val();
        let category = $("#category").val();
        let appStore = $("#appStore").val();
        let star = $("#star").val();
        let end = $("#end").val();
        tableIns.reload('dataTableId', {
            where: {
                star: star,
                end: end,
                imei: imei,
                phone: phone,
                masterPhone: masterPhone,
                category: category,
                appStore: appStore
            }
            , page: {}
        });
    }


    function showmsg(msg) {
        layer.msg(msg)
    }


    layui.use('laydate', function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#star'
            , type: 'datetime'

        });
        laydate.render({
            elem: '#end'
            , type: 'datetime'

        });
    });
</script>
<!--/请在上方写此页面业务相关的脚本-->
